package com.hqx.processcontrol;

import java.util.Arrays;

/**
 * Arrays类的常用方法
 * @author hqx
 * @version 2021-06-23
 */
public class ArraysTest {
    public static void main(String[] args) {

        int[] arr = new int[]{1,2,3,4};
        int[] arr2 = new int[]{1,3,2,4};
        //boolean equals(int[] a,int[] b)
        System.out.println("两个数组是否相等:"+Arrays.equals(arr,arr2));

        //String toString(int[] a)
        System.out.println(Arrays.toString(arr));

        //void sort(int[] a)
        Arrays.sort(arr2);
        System.out.println(Arrays.toString(arr2));

        //int binarySearch(int[] a,int key) 找到返回该元素在数组中的索引，否则返回-1
        System.out.println(Arrays.binarySearch(arr,0));
    }
}
